#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from dragon.selector import Selector
from dragon.page import DraPage
from pages.calendar import Calendar


class EarlyTradeSe:
    searchInput = Selector('input.searchInput', '搜索框')
    calendarButton= Selector('span.right-time','日历按钮')
    top3PlateButton=Selector('p.scrollbar-demo-item.cp','前三板块按钮')
    openVolumeSortButton=Selector('text=开盘量','开盘量排序按钮')
    auctionSortButton=Selector('text=竞/流','竞/流排序按钮')
    openVolumeSortIcon=Selector('div.sort>div:nth-child(2)>div>svg>use','开盘量排序图标')

    auctionSortIcon=Selector('div.sort>div:nth-child(3)>div>svg>use','竞/流排序图标')
    stockBlock=Selector('li.infinite-list-item','股票展示块')
    stockName=Selector('li.infinite-list-item>div>div:nth-child(1)>span','股票名称')
    noDataAlert = Selector('div.empty-text', '空数据提示')
    openVolume = Selector('div.item-name.fHalfOf3', '开盘量')
    # openVolume = Selector('li.infinite-list-item>div>div:nth-child(2)', '开盘量')
    auction=Selector('li.infinite-list-item>div>div:nth-child(3)','竞/流')

class EarlyTradePage:
    def __init__(self,draPage:DraPage):
        self.draPage = draPage
        self.searchInput=draPage.locator(EarlyTradeSe.searchInput)
        self.calendarButton=draPage.locator(EarlyTradeSe.calendarButton)
        self.top3PlateButton=draPage.locator(EarlyTradeSe.top3PlateButton)
        self.openVolumeSortButton=draPage.locator(EarlyTradeSe.openVolumeSortButton)
        self.auctionSortButton=draPage.locator(EarlyTradeSe.auctionSortButton)
        self.openVolumeSortIcon=draPage.locator(EarlyTradeSe.openVolumeSortIcon)
        self.auctionSortIcon=draPage.locator(EarlyTradeSe.auctionSortIcon)
        self.stockBlock=draPage.locator(EarlyTradeSe.stockBlock)
        self.stockName=draPage.locator(EarlyTradeSe.stockName)
        self.noDataAlert=draPage.locator(EarlyTradeSe.noDataAlert)
        self.openVolume=draPage.locator(EarlyTradeSe.openVolume)
        self.auction=draPage.locator(EarlyTradeSe.auction)

    def pick_date_by_index(self, index: int):
        self.calendarButton.click()
        calendar = Calendar(self.draPage)
        calendar.pick_date_by_index(index)








